<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

/* -------------------- 前台用户模块------------------  */

// 用户注册
Route::post("/user/register","UserController@register");
// 用户登录
Route::post("/user/login","UserController@login");
// 头像上传
Route::post("/user/upload","UserController@upload");

/* -------------------- 前台地址模块------------------  */
// 保存收货地址
Route::post("/address/store","userAddressesController@store");
// 更新收货地址
Route::post("/address/update","userAddressesController@update");
// 删除收货地址
Route::post("/address/delete","userAddressesController@delete");
// 用户地址列表
Route::get("/user/addresses","UserController@addresses");

// 商品一级分类
Route::get("/cate/home_list","CateController@home_list");
// 商品二级分类
Route::post("/cate/sub_list","CateController@sub_list");

// 获取一级分类下的商品
Route::post("/products/main_list","ProductsController@main_list");

// 获取二级分类下的商品
Route::post("/products/sub_list","ProductsController@sub_list");

// 商品详情
Route::post("/products/home_detail","ProductsController@home_detail");

// 单品保存购物车
Route::post("/cart/save","CartItemController@save");
// 批量保存购物车
Route::post("/cart/allsave","CartItemController@allsave");
// 购物车列表
Route::get("/carts","CartItemController@carts");
// 删除购物车
Route::post("/cart/del","CartItemController@del");


// 生成订单
Route::post("/order/create","ProductsController@create");
Route::get("/order/my_orders","ProductsController@my_orders");

// 后台api接口地址;
require_once('admin_api.php');

